import "./login.less"
var api = require('../../source/js/service.js');
var root = avalon.define({
	$id : "login",
	headerOpts:{
		currPath:'login'
	},
	errMes:'',
	user:"",
	password:"",
	remember:[],
	login:function(){
		this.errMes = ''
		if(this.user==''){
			this.errMes = '账号不能为空'
			return
		}
		if(this.password==''){
			this.errMes = '密码不能为空'
			return
		}
		var that = this
		return api.postItems({
			method:api.login,
			query:{
				no:this.user,
				password:this.password
			}
		},function(res){
			// avalon.log(res)
			if(res.success){
				var storage ;
				if(that.remember.length==1){
					storage = window.localStorage
				}else{
					storage = window.sessionStorage
				}
				var userInfo = JSON.stringify(res.data)
				storage.setItem('avaLessonEvaluationUser',userInfo)
				window.location = 'index.html'
			}else{
				that.errMes = res.message
			}
		})
	}
})




avalon.ready(function(){
	avalon.scan(document.body)
})